<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>使用ref来绑定页面dom，引入echart</title>
</head>

<body>
    <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.0/dist/echarts.js"></script>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <div id="Application">

        <!-- 为 ECharts 准备一个定义了宽高的 DOM -->
        <div style="width: 600px; height: 400px" ref="refChart"></div>
    </div>

    <script type="text/javascript">
        const App = Vue.createApp({
            setup() {
                //展示图表
                //	此dom为echarts图标展示dom
                //获取dom节点
                const refChart = Vue.ref();
                //展示表格
                const showChat = () => {
                    // 基于准备好的dom，初始化echarts实例
                    const myChart = echarts.init(refChart.value);

                    // 指定图表的配置项和数据
                    const option = {
                        title: {
                            text: "ECharts 入门示例",
                        },
                        tooltip: {},
                        legend: {
                            data: ["作者一"],
                        },
                        xAxis: {
                            data: ["周一", "周二", "周三", "周四", "周五", "周六", "周七"],
                        },
                        yAxis: {},
                        series: [
                            {
                                name: "作者一",
                                type: "bar",
                                data: [55, 22, 16, 18, 30, 22, 26],
                            },
                        ],
                    };
                    // 使用刚指定的配置项和数据显示图表。
                    myChart.setOption(option);
                }



                Vue.onMounted(() => {
                    showChat();//首次加载
                });
                return {
                    refChart,//获取节点用

                };
            },
        });
        App.mount("#Application");
    </script>
</body>

</html>